using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
//using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
//using InsigniaLibrary;
using Curriculum.DataAccess;
//using System.Net.Mail;
using System.Net;
using System.Web.Configuration;

/// <summary>
/// Summary description for Util
/// </summary>
namespace Curriculum.Db4oHttpModule
{
	public class Util
	{
		#region Methods

		/// <summary>
		/// limpia los controles hijos de un contenedor
		/// </summary>
		/// <param name="controlCollection"></param>
		public static void ClearControls(ControlCollection controlCollection)
		{
			foreach (Control control in controlCollection)
			{
				if (control.GetType() == typeof(TextBox))
				{
					(control as TextBox).Text = string.Empty;                
				}
				if (control.GetType() == typeof(CheckBox))
				{
					(control as CheckBox).Checked = false;
				}
			}
		}

		/// <summary>
		/// envia el mail al usuario
		/// </summary>
		/// <param name="code"> codigo del usuario </param>
//		public static void SendMail(User user, string message)
//		{
//			try
//			{
//				string body = string.Format(Resources.Resources.MailBodyFormat,message);
//				using (MailMessage mail = new MailMessage(WebConfigurationManager.AppSettings["SmtpSender"], user.Mail, Resources.Resources.MailSubject, body))
//				{
//					mail.IsBodyHtml = true;
//					SmtpClient client = new SmtpClient(WebConfigurationManager.AppSettings["SmtpServerAddress"]);
//					client.Credentials = new NetworkCredential(WebConfigurationManager.AppSettings["SmtpSender"],
//						WebConfigurationManager.AppSettings["SmtpSenderKey"]);
//					client.Send(mail);
//				}
//			}
//			catch(Exception ex)
//			{
//				throw ex;
//			}
//		}

		#endregion methods
	}
}
